package org.teamh.logic.datamodel;

import java.util.HashMap;

public class Guide {

	private CreepSmashGame game;
	private String ID;
	private HashMap<String, CreepTypeToCreepMapping> creepMapping = new HashMap<String, CreepTypeToCreepMapping>();
	private HashMap<String, TowerTypeToTowerMapping> towerMapping = new HashMap<String, TowerTypeToTowerMapping>();
	
	public Guide(String ID) {
		this.ID = ID;
	}
	
	public CreepSmashGame getGame() {
		return this.game; 
	}
	
	public void setGame(CreepSmashGame game) {
		if(this.game != game) {
			if(getGame() != null) {
				CreepSmashGame oldGame = getGame();
				this.game = null;
				oldGame.setGuide(null);
			}
			this.game = game;
			if(getGame() != null) {
				getGame().setGuide(this);
			}
		}
	}
	
	public void addCreepTypeToCreepMapping(CreepTypeToCreepMapping creep) {
		if(!creepMapping.containsKey(creep.getID())) {
			creepMapping.put(creep.getID(), creep);
			creep.setGuide(this);
		}
	}
	
	public void removeCreepTypeToCreepMapping(CreepTypeToCreepMapping creep) {
		if(creepMapping.remove(creep.getID()) != null) {
			creep.setGuide(null);
		}
	}
	
	public void addTowerTypeToTowerMapping(TowerTypeToTowerMapping tower) {
		if(!towerMapping.containsKey(tower.getID())) {
			towerMapping.put(tower.getID(), tower);
			tower.setGuide(this);
		}
	}
	
	public void removeTowerTypeToTowerMapping(TowerTypeToTowerMapping tower) {
		if(towerMapping.remove(tower.getID()) != null) {
			tower.setGuide(null);
		}
	}
	
	public TowerTypeToTowerMapping getTowerMapping(String ID) {
		return towerMapping.get(ID);
	}
	
	public CreepTypeToCreepMapping getCreepMapping(String ID) {
		return creepMapping.get(ID);
	}

	public String getID() {
		return ID;
	}

	public void setID(String iD) {
		ID = iD;
	}
	
}
